package com.good.entity;


import java.util.Date;

import javax.persistence.Access;
import javax.persistence.AccessType;
import javax.persistence.Basic;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;

@Entity
@Table(name = "xx_a")
@SequenceGenerator(name="myGenerator",sequenceName="xx_test_generator")
@Access(AccessType.FIELD)
public class A  extends BaseEntity{
	/**
	 * 
	 */
	public enum EnumDemo{
		A,B,C
	}
	private static final long serialVersionUID = 489108172833449254L;
	//EnumType.ORDINAL这个是默认的,一顺序排列
	//字符串的形式，就是是什么就存什么eg:A
	@Enumerated(EnumType.STRING)
	//这个默认是eager的
	@Basic(fetch=FetchType.LAZY)
	private EnumDemo enumDemo;
	/**
	 * TemporalType.DATE 就存日期
	 * 
	 * TemporalType.TIME就存时间
	 * 
	 * TemporalType.TIMESTAMP存时间戳
	 */
	@Temporal(TemporalType.TIMESTAMP)
	private Date date;
	
	public Date getDate() {
		return date;
	}

	public void setDate(Date date) {
		this.date = date;
	}

	public EnumDemo getEnumDemo() {
		return enumDemo;
	}

	public void setEnumDemo(EnumDemo enumDemo) {
		this.enumDemo = enumDemo;
	}

	@Transient
	private String str;
	/**
	 * @Access(AccessType.FIELD) 这样就可以处理一些字段了
	 * @return
	 */
	@Access(AccessType.PROPERTY)
	public String getStr() {
		if(str.length()<=1){
			return "good";
		}
		return str;
	}

	public void setStr(String str) {
		this.str = str;
	}
}
